# 示例 10: 协程与回调（将回调转换为协程）
import asyncio


def callback(future):
    print("Callback executed")
    future.set_result("Result from callback")


async def use_callback():
    loop = asyncio.get_running_loop()
    future = loop.create_future()
    future.add_done_callback(callback)
    result = await future
    print(result)


async def main():
    await asyncio.sleep(1)  # 模拟一些前置操作
    await use_callback()


asyncio.run(main())